{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "qR-vG2CF4jaz"
   },
   "source": [
    "# Causal Games\n",
    "\n",
    "This notebook walks through a few examples for building intuition about backdoor paths used in *The Book of Why* by Judea Pearl. \n",
    "\n",
    "For each example, we take an example causal graph represented as a *Directed Acyclic Graph* (DAG), and our goal is to identify the set of deconfounders (often denoted $Z$) that will close all backdoor (a.k.a biasing) paths from nodes $X$ to $Y$. A backdoor path is any undirected path from $ X $ to $ Y $ that starts with an arrow into $ X $, i.e., contains an edge pointing into $ X $."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "cellView": "both",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "id": "EkFVGD3Tv7ma",
    "outputId": "a3fd160d-dcdf-4495-e8ea-e5b3aedadaf5"
   },
   "outputs": [],
   "source": [
    "# Imports\n",
    "\n",
    "from pgmpy.base import DAG\n",
    "from pgmpy.identification import Adjustment, Frontdoor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 1\n",
    "\n",
    "Although the following example is simple, many analysts include $ A $ and/or $ B $ *for good measure*. Because $ A $ lies on the path $ X \\rightarrow A \\rightarrow Y $, it is a mediator; conditioning on $ A $ closes this path and attenuates the estimated total effect of $ X $ on $ Y $."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "cellView": "form",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 201
    },
    "colab_type": "code",
    "id": "P90trQAQ7Clc",
    "outputId": "2e62d5b8-de0e-4e28-b14d-5c03bcd1ab61"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAACZCAYAAAAl13YcAAAAOnRFWHRTb2Z0d2FyZQBNYXR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cVgMNiWKSktLcVkMlHz69Xr9QwaNIjFixc7tE6R4FwioPcpk8lEQkIC3377LUePHiUvL4+qqiokSUKn0+Hu7k7r1q3p06cPoaGh9OrVS+zK3odEQAVBxcRbqiComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCCo2P8DhjLCA/kKqlwAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 212.598x133.858 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example1 = DAG([('X', 'A'),\n",
    "            ('A', 'Y'),\n",
    "            ('A', 'B')],\n",
    "           roles={'exposure': 'X', 'outcome': 'Y'})\n",
    "\n",
    "example1.to_daft(node_pos={'X': (0, 0), 'Y': (2, 0), 'A': (1, 0), 'B': (1, -1)}).render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "cellView": "both",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "id": "yQyYJEC83ODX",
    "outputId": "07597081-bbec-4209-db8f-b731de34ae3a"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Are there any active backdoor paths? False\n",
      "No. of potential adjustment sets: 1\n",
      "If so, what are the possible backdoor adjustment sets? []\n"
     ]
    }
   ],
   "source": [
    "# @markdown Notice how there are no nodes with arrows pointing into X.  Said another way, X has no parents.  Therefore, there can't be any backdoor paths confounding X and Y.  pgmpy will confirm this in the following way:\n",
    "\n",
    "needs_adjustment = Adjustment().validate(example1)\n",
    "print(\n",
    "    f\"Are there any active backdoor paths? {not needs_adjustment}\"\n",
    ")\n",
    "\n",
    "adjusted_graphs, success = Adjustment(variant=\"all\").identify(example1)\n",
    "\n",
    "print(f\"No. of potential adjustment sets: {len(adjusted_graphs)}\")\n",
    "\n",
    "all_adjustment_sets = [str(graph.get_role('adjustment')) for graph in adjusted_graphs]\n",
    "print(f\"If so, what are the possible backdoor adjustment sets? {', '.join(all_adjustment_sets)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 2\n",
    "\n",
    "This graph is a bit more complex, but it is also trivial to solve.  The key is noticing that there is only one backdoor path between $ X $ and $ Y $, which goes from $ X \\leftarrow A \\rightarrow B \\leftarrow D \\rightarrow E \\rightarrow Y $. However, as this path has a collider structure at $ B $ (a.k.a a 'V-Structure') because of $ A \\rightarrow B \\leftarrow D $, this path is *not active* and hence not a backdoor path."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "cellView": "form",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 258
    },
    "colab_type": "code",
    "id": "b5RJ0UsH_kQ4",
    "outputId": "3e4f9430-fca7-40d4-f8b3-ffd241c6a8f8"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAADoCAYAAADlqah4AAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjUsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvWftoOwAAAAlwSFlzAAAPYQAAD2EBqD+naQAAM0lJREFUeJzt3XlcVPX+x/HXDMOOLIKCqLimpAImorlvqZG45HKprsXNLLU0U9HESsV9KSuXzK6WqTeXkFJTlFyon2kuJGqoJKAYGhqKIgwDDHN+f/hgrmaZzJyZc/R+n48Hj0eNzPf7mcO85yzz/X6PRpIkCUEQVEmrdAGCIPw1EVBBUDERUEFQMRFQQVAxEVBBUDERUEFQMRFQQVAxEVBBUDERUEFQMRFQQVAxEVBBUDERUEFQMRFQQVAxEVBBUDERUEFQMZ3SBQAYjUb27NlDcnIyV69exWAw4OzsjJeXF926dSMyMhIXFxely1SlwsJCtm7dyoEDBygqKqK8vBwXFxc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oqIjo6ml27dlFRUYGLiwvt2rWjffv2tGrV6i8/6IxGI2lpaRw8eJAffvjBvN07depEYmKiLHM974ukgMOHD0udOnWStFqtBEiApNVqJR8fHykwMFAKCgqSateuLfn6+koODg7m3wGkVq1aSTt37lSibFX4/PPPpUceeeSObeLo6CjVqFFDqlOnjhQUFCQFBgZKXl5ekkajMf+OTqeToqKipMzMTKVfgiJKSkqkuLg4ydfX945t5+rqKgUEBEh169aV6tatKwUEBEhubm53/I6np6f0+uuvSzdv3rR73Xbdg/6R0Whkz549fPPNNxw8eJBz585RWlpKRUUFWq0WJycngoKCaNOmDU899RSRkZGyLCPxMCgsLGTr1q3s3LmT1NRULl26hNFoNK8P5erqSpMmTejQoQP9+/enXbt2D+2hbFVduHCBhIQE9u7dy8mTJykoKDAvq6LT6fD09KRFixZ07dqVQYMG8cgjjyhWq6IBFQTh3sRHqiComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCComAioIKiYCKggqJgIqCCo2P8DJMUDmgEOU/4AAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 212.598x212.598 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example2 = DAG([('X', 'E'), \n",
    "             ('A', 'X'), \n",
    "             ('A', 'B'), \n",
    "             ('B', 'C'), \n",
    "             ('D', 'B'), \n",
    "             ('D', 'E'), \n",
    "             ('E', 'Y')],\n",
    "            roles={'exposure': 'X', 'outcome': 'Y'})\n",
    "\n",
    "example2.to_daft(node_pos={'X': (1, 1), 'Y': (3, 1), 'A': (1, 3), 'B': (2, 3), 'C': (3, 3), 'D': (2, 2), 'E': (2, 1)}).render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "id": "2d6Ezs6PDDON",
    "outputId": "c597c0df-3271-4e8e-9a68-3200c7f105a5"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Are there any active backdoor paths? False\n",
      "No. of potential adjustment sets: 4\n",
      "If so, what are the possible backdoor adjustment sets? [], ['A'], ['D'], ['A', 'D']\n",
      "What is the minimal possible backdoor adjustment set? []\n"
     ]
    }
   ],
   "source": [
    "needs_adjustment = Adjustment().validate(example2)\n",
    "print(\n",
    "    f\"Are there any active backdoor paths? {not needs_adjustment}\"\n",
    ")\n",
    "\n",
    "adjusted_graphs, success = Adjustment(variant=\"all\").identify(example2)\n",
    "\n",
    "print(f\"No. of potential adjustment sets: {len(adjusted_graphs)}\")\n",
    "\n",
    "all_adjustment_sets = [str(graph.get_role('adjustment')) for graph in adjusted_graphs]\n",
    "print(f\"If so, what are the possible backdoor adjustment sets? {', '.join(all_adjustment_sets)}\")\n",
    "\n",
    "adjusted_graph, success = Adjustment(variant=\"minimal\").identify(example2)\n",
    "print(f\"What is the minimal possible backdoor adjustment set? {adjusted_graph.get_role('adjustment')}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3\n",
    "\n",
    "This example actually requires adjustment, as it has open backdoor paths. The path $ X \\leftarrow B \\rightarrow Y $ is an open backdoor path in the DAG with $ B $ as the common cause for both $ X $ and $ Y $. The other path $ X \\rightarrow A \\leftarrow B \\rightarrow Y $ is not active because of the V-Structure at $ A $. Hence, conditioning just on the variable $ B $ would block all backdoor paths."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "cellView": "form",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 258
    },
    "colab_type": "code",
    "id": "Pg6T2WA3DZ8n",
    "outputId": "5d79efd3-b8f7-46a8-dcf0-da2b7997be3c"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAO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RUqNVqTJ48Gb169RJk7FOnTiE2NhY6nQ7t27dHamqqVVeyFOUJ21qtFoMHD0ZKSgpUKhW6dOmC8ePHm+88r46SkhKsW7cOqampKC8vR5s2bXDw4EGr/QUjNVdCQgLGjBkDnU4HLy8vjBo1yuLrso8fP44NGzYgJydH1EAQpUFNEhMTMWXKFNy5cwcA0KhRI/Tq1Qvdu3d/7t0E+fn5OHbsGI4cOYJr166B4zi4urpi3rx5mDhxoljlkxqopKQEI0eORHJyMoxGIxwcHNC1a1d069YN7dq1e+ajMQ0GA86ePYv09HQcO3YMpaWlYBgGPXr0wPbt28V7ah4ngZMnT3I9evTgGIbhAHAAOIZhuPr163NeXl5co0aNuIYNG3Jubm6cUqk0fw8Arl27dtz+/fulKJvUYGVlZdysWbM4Nze3StuTo6Mj5+npyXl7e3Pe3t6cp6cn5+TkVOl7XFxcuMmTJ3PFxcWi1y1qgj7JYDAgJSUFu3fvRnp6Om7cuIHy8nIYjUYwDAO1Wo1GjRqhU6dOeOuttzBw4EBBlpEgtu3WrVtITEzE4cOHceHCBRQWFpqXVVGpVHBxcYG/vz969+6N4cOHo1mzZpLVKmmDEkKejy5UJUTGqEEJkTFqUEJkjBqUEBmjBiVExqhBCZExalBCZIwalBAZowYlRMaoQQmRMWpQQmSMGpQQGaMGJUTGqEEJkTFqUEJkjBqUEBn7f5pNwhO4Zkg9AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 212.598x212.598 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example3 = DAG([('X', 'Y'),\n",
    "             ('X', 'A'),\n",
    "             ('B', 'A'),\n",
    "             ('B', 'X'),\n",
    "             ('B', 'Y')],\n",
    "            roles={'exposure': 'X', 'outcome': 'Y'})\n",
    "\n",
    "example3.to_daft(node_pos={'X': (1, 1), 'Y': (3, 1), 'A': (2, 1.75), 'B': (2, 3)}).render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "id": "l0GI2mM3WQeI",
    "outputId": "7ca879e8-e678-42d9-9d03-404ffb67c51c"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Are there any active backdoor paths? True\n",
      "No. of potential adjustment sets: 1\n",
      "If so, what are the possible backdoor adjustment sets? ['B']\n"
     ]
    }
   ],
   "source": [
    "needs_adjustment = Adjustment().validate(example3)\n",
    "print(\n",
    "    f\"Are there any active backdoor paths? {not needs_adjustment}\"\n",
    ")\n",
    "\n",
    "adjusted_graphs, success = Adjustment(variant=\"all\").identify(example3)\n",
    "\n",
    "print(f\"No. of potential adjustment sets: {len(adjusted_graphs)}\")\n",
    "\n",
    "all_adjustment_sets = [str(graph.get_role('adjustment')) for graph in adjusted_graphs]\n",
    "print(f\"If so, what are the possible backdoor adjustment sets? {', '.join(all_adjustment_sets)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 4\n",
    "\n",
    "This *DAG* structure is commonly known as the \"M Bias\" example because of the shape of the *DAG*. This is also a common example where classical analysts might want to adjust/control for the variable $ B $  as it is a pre-treatment variable. However, as we can see that the only backdoor path $ X \\leftarrow A \\rightarrow B \\leftarrow C \\rightarrow Y $ is not active due to the V-structure at $ B $. Hence, no adjustment is needed in this case. But if we adjust for the variable $ B $, it would activate the V-structure, making the path $ X \\leftarrow A \\rightarrow B \\leftarrow C \\rightarrow Y $ active.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "cellView": "form",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 258
    },
    "colab_type": "code",
    "id": "XP2ORZw8EtyZ",
    "outputId": "9f267191-b408-483b-87d9-754c949a7d72"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png":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bzkUgK2L9/v/TSSy9JWq1WAiRA0mq1UvHixaWgoCApODhYKlOmjOTn5yfpdDrb9wBS3bp1pW3btinRtvAEy87OlkaOHCn5+fkVeD15enpKgYGBUrly5aRy5cpJgYGBkpeXV4HvKVq0qPThhx9Kd+7ccXnfLt2C/p3ZbGbHjh1s2rSJxMREzp07R05ODhaLBa1Wi7u7O8HBwTRs2JDXX3+diIgIWZaREAq3CxcuEBcXx86dOzl69Cg3btywrd6h1+spWrQotWrVolmzZnTs2JHKlSsr1quiARUE4eHERFVBUDERUEFQMRFQQVAxEVBBUDERUEFQMRFQQVAxEVBBUDERUEFQMRFQQVAxEVBBUDERUEFQMRFQQVAxEVBBUDERUEFQMRFQQVAxEVBBULH/BygVYTA7RHWfAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 212.598x212.598 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example4 = DAG([('A', 'X'),\n",
    "             ('A', 'B'),\n",
    "             ('C', 'B'),\n",
    "             ('C', 'Y')],\n",
    "            roles={'exposure': 'X', 'outcome': 'Y'})\n",
    "example4.to_daft(node_pos={'X': (1, 1), 'Y': (3, 1), 'A': (1, 3), 'B': (2, 2), 'C': (3, 3)}).render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "id": "CBaGzLKSFmnQ",
    "outputId": "95c1c6a5-dbe3-4768-8f37-94d9547e9db6"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Are there any active backdoor paths? False\n",
      "No. of potential adjustment sets: 4\n",
      "If so, what are the possible backdoor adjustment sets? [], ['A'], ['C'], ['A', 'C']\n"
     ]
    }
   ],
   "source": [
    "needs_adjustment = Adjustment().validate(example4)\n",
    "print(\n",
    "    f\"Are there any active backdoor paths? {not needs_adjustment}\"\n",
    ")\n",
    "\n",
    "adjusted_graphs, success = Adjustment(variant=\"all\").identify(example4)\n",
    "\n",
    "print(f\"No. of potential adjustment sets: {len(adjusted_graphs)}\")\n",
    "\n",
    "all_adjustment_sets = [str(graph.get_role('adjustment')) for graph in adjusted_graphs]\n",
    "print(f\"If so, what are the possible backdoor adjustment sets? {', '.join(all_adjustment_sets)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 5\n",
    "\n",
    "This is the last example in The Book of Why. In this case, we have two backdoor paths, \n",
    "1. $ X \\leftarrow A \\rightarrow B \\leftarrow C \\rightarrow Y $\n",
    "2. $ X \\leftarrow B \\leftarrow C \\rightarrow Y $.\n",
    "\n",
    "The first backdoor path is not active due to the V-structure at $ B $, however, the second one is active. To control for the second backdoor path, one option is to condition on the variable $ B $, but doing that makes the first backdoor path active, requiring additionally conditioning on $ A $ or $ C $. Another possibility is to simply condition on $ C $ which would block the second backdoor path without activating the first one."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "cellView": "form",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 258
    },
    "colab_type": "code",
    "id": "ZAbSVPvZFxZH",
    "outputId": "88a7fff6-0744-4dda-b5e9-8d93dcea84d7"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAADoCAYAAADlqah4AAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjUsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvWftoOwAAAAlwSFlzAAAPYQAAD2EBqD+naQAAKSZJREFUeJzt3Xl4TOf///HnLNmDkJAIEkvsgopYStVSTVP73vrQVFG1NZag1J5S0top+tEvRYtIqV18ilRVal9jTRC1hCZBJJNtZs7vD79MpZYmM2cWcj+uy3XVyLzv96TzmrPMfe6jkCR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flKX20aNHiYiIICsri4CAAGJiYsy6kqVF7rCt0Wjo2LEje/fuRa1W06RJEwYMGGC48rww0tPTWbVqFTExMWRnZ1O/fn3+97//me0TTHh5bdiwgQ8//JCsrCy8vb157733jJ6X/ccff7B27VoSExMtukGwSEDzREVFERoayu3btwHw8fHhzTffpFmzZi+8miA5OZnff/+dAwcOcOXKFSRJolSpUoSHhzNkyBBLtS+8hNLT0+nVqxfR0dHodDocHR1p2rQpr7/+Og0aNMDe3v6Zz9NqtZw6dYrY2Fh+//13MjIyUCqVvPHGG2zatEmWaz0LRLKCI0eOSG+88YakVColQAIkpVIplSxZUvL29pZ8fHykcuXKSe7u7pJKpTL8DCA1aNBA2r17tzXaFl5imZmZ0vjx4yV3d/d87ycnJyfJy8tLqlChglShQgXJy8tLcnZ2zvczxYsXlz799FPp0aNHFu/bolvQf9Jqtezdu5ft27cTGxvLtWvXyM7ORqfToVQqsbe3x8fHh0aNGvHuu+8SHBwsyzISQtF248YNoqKi2LdvH2fPnuX+/fuGZVXUajXFixenTp06tGzZkm7dulG1alWr9WrVgAqC8GJioqog2DARUEGwYSKggmDDREAFwYaJgAqCDRMBFQQbJgIqCDZMBFQQbJgIqCDYMBFQQbBhIqCCYMNEQAXBhomACoINEwEVBBsmAioINkwEVBBs2P8DvQPyPcagLEUAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 212.598x212.598 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example5 = DAG([('A', 'X'),\n",
    "             ('A', 'B'),\n",
    "             ('C', 'B'),\n",
    "             ('C', 'Y'),\n",
    "             ('X', 'Y'),\n",
    "             ('B', 'X')],\n",
    "             roles={'exposure': 'X', 'outcome': 'Y'})\n",
    "\n",
    "example5.to_daft(node_pos={'X': (1, 1), 'Y': (3, 1), 'A': (1, 3), 'B': (2, 2), 'C': (3, 3)}).render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "id": "IF1jYMq_eNHd",
    "outputId": "68bcc15d-c1aa-40c4-fb61-b400e7c31abe"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Are there any active backdoor paths? True\n",
      "No. of potential adjustment sets: 5\n",
      "If so, what are the possible backdoor adjustment sets? ['C'], ['A', 'B'], ['A', 'C'], ['B', 'C'], ['A', 'B', 'C']\n"
     ]
    }
   ],
   "source": [
    "needs_adjustment = Adjustment().validate(example5)\n",
    "print(\n",
    "    f\"Are there any active backdoor paths? {not needs_adjustment}\"\n",
    ")\n",
    "\n",
    "adjusted_graphs, success = Adjustment(variant=\"all\").identify(example5)\n",
    "\n",
    "print(f\"No. of potential adjustment sets: {len(adjusted_graphs)}\")\n",
    "\n",
    "all_adjustment_sets = [str(graph.get_role('adjustment')) for graph in adjusted_graphs]\n",
    "print(f\"If so, what are the possible backdoor adjustment sets? {', '.join(all_adjustment_sets)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 6\n",
    "\n",
    "This example is drawn from Causality by Pearl on p. 80. This is similar to Example 5, but because $ D $ is now a common cause of $ X $ and $ Y $, it requires us to condition on $ D $. But similar to the last example, this leads to the activation of the other path $ X \\leftarrow C \\leftarrow A \\rightarrow D \\leftarrow B \\rightarrow E \\rightarrow Y $. To block this path, we will need to additionally condition on one of: $ C $, $ A $, $ B $, or $ E $."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "cellView": "form",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 258
    },
    "colab_type": "code",
    "id": "dSjZqd5fHF06",
    "outputId": "05857131-230d-4dd9-88d0-25d4b800eb68"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUh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GDJAgY9th7NixzJkzB3haAK1///6SDD/v37/PpEmTSEhIwNvbmz179ki63cra5OTkEBISwoEDB7C3t+ezzz7jnXfekST28ePHmTt3LhqNhtq1a3PgwAGzVrK0yBO2MzMzad++Pfv27UOtVtOgQQP69u1r2HleENLT01m5ciUHDhwgOzubWrVq8fPPP5vtDGZtLl++TKtWrbh79y6urq60bt2arl27GrXJOz4+nhUrVnDmzBlEUSQiIsLwhOrXkfXr1/Pxxx+j0Wjw9/enW7duRq/L/uOPP1i7di3x8fEW7RAsIqieqKgohg4dSkJCAvB0J8c777xD48aNX7mbICkpid9//52DBw9y/fp1RFHEy8uL6dOnM2jQIEulb1XGjh3LwoULycjIQKlUEhQUxNtvv03Dhg1fWTIlNjaWI0eOcODAAUMJzcDAQNauXUv9+vUtlb7VSE9Pp2vXrsTExKDT6XB0dKRhw4Y0atSI4ODgl57otFotZ86c4ciRI/z++++G4/72228THR0tyV7PfCFagWPHjolvv/22qFQqRUAERKVSKXp6eor+/v5iQECAWKJECdHb21tUqVSGvwHE4OBgcffu3dZI2yZYtWqVWKFChTzHxM7OTixatKhYsmRJMSAgQPT39xfd3d1FhUJh+Bu1Wi22bdtWjI2NtfZHsApZWVni2LFjRW9v7zzHzsnJSfTz8xNLlSollipVSvTz8xOdnZ3z/I2bm5v42WefiU+ePLF43hbtQf+OVqtl3759bN++nSNHjnDz5k2ys7PR6XQolUrs7e0JCAigXr16tG7dmtDQUEnKSLwOpKWlsXXrVnbv3s3JkydJSEhAq9Ua6kM5OTlRsWJFGjduTFhYGA0bNnxth7IF5fbt20RFRfHLL79w/vx5UlJSDGVV1Go1bm5uVK9enWbNmtGpUycqVKhgtVytKqiMjMyrkU+pMjI2jCyojIwNIwsqI2PDyILKyNgwsqAyMjaMLKiMjA0jCyojY8PIgsrI2DCyoDIyNowsqIyMDSMLKiNjw8iCysjYMLKgMjI2jCyojIwNIwsqI2PDyILKyNgw/weayiLSHxqW1AAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 212.598x212.598 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example6 = DAG([('X', 'F'),\n",
    "             ('F', 'Y'),\n",
    "             ('C', 'X'),\n",
    "             ('A', 'C'),\n",
    "             ('A', 'D'),\n",
    "             ('D', 'X'),\n",
    "             ('D', 'Y'),\n",
    "             ('B', 'D'),\n",
    "             ('B', 'E'),\n",
    "             ('E', 'Y')],\n",
    "            roles={'exposure': 'X', 'outcome': 'Y'})\n",
    "example6.to_daft(node_pos={'X': (1, 1), 'Y': (3, 1), 'A': (1, 3), 'B': (3, 3), 'C': (1, 2), 'D': (2, 2), 'E': (3, 2), 'F': (2, 1)}).render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 68
    },
    "colab_type": "code",
    "id": "30OIiRt7raN2",
    "outputId": "4c285443-724c-4988-b9a6-2ad2fcf2654e"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Are there any active backdoor paths? True\n",
      "No. of potential adjustment sets: 15\n",
      "If so, what are the possible backdoor adjustment sets? ['D', 'E'], ['D', 'B'], ['A', 'D'], ['C', 'D'], ['D', 'B', 'E'], ['A', 'D', 'E'], ['C', 'D', 'E'], ['A', 'D', 'B'], ['C', 'D', 'B'], ['C', 'A', 'D'], ['A', 'D', 'B', 'E'], ['C', 'D', 'B', 'E'], ['C', 'A', 'D', 'E'], ['C', 'A', 'D', 'B'], ['C', 'A', 'D', 'B', 'E']\n",
      "What is the minimal possible backdoor adjustment set? ['C', 'D']\n"
     ]
    }
   ],
   "source": [
    "needs_adjustment = Adjustment().validate(example6)\n",
    "print(\n",
    "    f\"Are there any active backdoor paths? {not needs_adjustment}\"\n",
    ")\n",
    "\n",
    "adjusted_graphs, success = Adjustment(variant=\"all\").identify(example6)\n",
    "\n",
    "print(f\"No. of potential adjustment sets: {len(adjusted_graphs)}\")\n",
    "\n",
    "all_adjustment_sets = [str(graph.get_role('adjustment')) for graph in adjusted_graphs]\n",
    "print(f\"If so, what are the possible backdoor adjustment sets? {', '.join(all_adjustment_sets)}\")\n",
    "\n",
    "adjusted_graph, success = Adjustment(variant=\"minimal\").identify(example6)\n",
    "print(f\"What is the minimal possible backdoor adjustment set? {adjusted_graph.get_role('adjustment')}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 7\n",
    "\n",
    "This example shows an example where a backdoor adjustment is not possible. In this case, $ B $ is a latent variable and hence can not be conditioned on, making it impossible to block the backdoor path $ X \\leftarrow B \\rightarrow Y $. However, another criterion called the Frontdoor Criterion can be applied here to identify the effect of $ X $ on $ Y $."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "cellView": "form",
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 201
    },
    "colab_type": "code",
    "id": "Z4pkuyOwM9xq",
    "outputId": "82e581df-b378-423c-95bd-d16b901c5296"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAACZCAYAAAAl13YcAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjUsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvWftoOwAAAAlwSFlzAAAPYQAAD2EBqD+naQAAH2xJREFUeJzt3Xl8TPf+x/HXbNkjlpA0SC0RKtbETolUKYK0qlHXJa21Sl2taukttZWmm1p6oxelqoSIUnuLaKspkgiuXZBKSYhYso3JzJzfH36ZSlsqM2fmTOr7fDz80XTm8/2cSd5zlvme76gkSZIQBMEpqZVuQBCEexMBFQQnJgIqCE5MBFQQnJgIqCA4MRFQQXBiIqCC4MREQAXBiYmACoITEwEVBCcmAioITkwEVBCcmAioIDgxEVBBcGIioILgxLRKN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/OBSAo4cOCA9Pjjj0tqtVoCJEBSq9VSlSpVpICAACkwMFCqWbOmVK1aNUmj0VgeA0ihoaHS9u3blWjbKaxYsUJq0KBBmddEp9NJ1atXl2rVqiUFBgZKAQEBko+Pj6RSqSyP0Wq1UmRkpHT27FmlN0ERxcXF0uTJk6Vq1aqVee3c3d0lf39/qXbt2lLt2rUlf39/ycPDo8xjKlWqJL3yyitSfn6+w/t26B7094xGI7t27WLz5s0kJydz/vx5bt++jclkQq1W4+LiQmBgIG3atKFXr1707NlTtvVjK7pbt26xadMmtm/fTmpqKpcuXcJoNFrWh3J3dyc4OJiOHTvSr18/2rdv/7c9lC2vX375hYSEBHbv3s3Ro0e5fv26ZVkVrVZLpUqVaNKkCeHh4fTv358GDRoo1quiARUE4f7EW6ogODERUEFwYiKgguDEREAFwYmJgAqCExMBFQQnJgIqCE5MBFQQnJgIqCA4MRFQQXBiIqCC4MREQAXBiYmACoITEwEVBCcmAioITkwEVBCc2P8BQWTW/d1P2kcAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 212.598x133.858 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "example7 = DAG([('X', 'A'), ('A', 'Y'), ('B', 'X'), ('B', 'Y')], latents={'B'}, roles={'exposure': 'X', 'outcome': 'Y'})\n",
    "example7.to_daft(node_pos={'X': (1, 1), 'Y': (3, 1), 'A': (2, 1), 'B': (2, 2)}).render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 68
    },
    "colab_type": "code",
    "id": "m8DZd_FQ4uLV",
    "outputId": "b73751d4-8aa9-4ec1-ba10-d509fe13c1a1"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Are there any active backdoor paths? True\n",
      "Are there any set of variables to block the backdoor paths? False\n",
      "Possible frontdoor adjustment variables?: ['A']\n"
     ]
    }
   ],
   "source": [
    "needs_adjustment = Adjustment().validate(example7)\n",
    "print(\n",
    "    f\"Are there any active backdoor paths? {not needs_adjustment}\"\n",
    ")\n",
    "\n",
    "adjusted_graphs, success = Adjustment(variant=\"all\").identify(example7)\n",
    "all_adjustment_sets = [str(graph.get_role('adjustment')) for graph in adjusted_graphs]\n",
    "print(f\"Are there any set of variables to block the backdoor paths? {success}\")\n",
    "\n",
    "adjusted_graph, success = Frontdoor().identify(example7)\n",
    "print(f\"Possible frontdoor adjustment variables?: {adjusted_graph.get_role('frontdoor')}\")"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "include_colab_link": true,
   "name": "Causal Games.ipynb",
   "provenance": [],
   "toc_visible": true,
   "version": "0.3.2"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
